package abc.hd.com.ggl;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
*@Author hd
*@Date 2021/11/14 17:49
*@Description
*/
public class DateUtil {
    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    /**
    *@Author hd
    *@Date 2021/11/14 17:50
    *@Description
    */
    public static Date stringToDate(String date) {
        try {
            return sdf.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
     *@Author hd
     *@Date 2021/11/14 17:50
     *@Description日期转字符串
     */

    public static String dateToString(Date date) {
        return sdf.format(date);
    }
  /**
  *@Author hd
  *@Date 2021/11/14 17:50
  *@Description  util的日期转为sql的日期
  */
    public static java.sql.Date utilDateToSqlDate(Date datd){
        return new java.sql.Date(datd.getTime());
    }
   /**
   *@Author hd
   *@Date 2021/11/14 17:51
   *@Description  字符串为sql的日期
   */
    public static java.sql.Date StringToSqlDate(String date){
        return new java.sql.Date(stringToDate(date).getTime());
    }

}
